package cn.qj.ymcc.service.impl;

import cn.qj.ymcc.domain.CourseChapter;
import cn.qj.ymcc.mapper.CourseChapterMapper;
import cn.qj.ymcc.service.ICourseChapterService;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 课程章节 ， 一个课程，多个章节，一个章节，多个视频 服务实现类
 * </p>
 *
 * @author whale
 * @since 2025-07-24
 */
@Service
public class CourseChapterServiceImpl extends ServiceImpl<CourseChapterMapper, CourseChapter> implements ICourseChapterService {

    /**
     * 根据课程id查询章节列表
     *
     * @param courseId
     * @return
     */
    @Override
    public List listByCourseId(Long courseId) {
        Wrapper<CourseChapter> ww = new EntityWrapper<CourseChapter>()
                .eq("course_id", courseId)
                .orderBy("number", false);

        List<CourseChapter> courseChapters = selectList(ww);
        return courseChapters;
    }
}
